
import {registerTwoPhaseEvent} from './EventRegistry';
//i是原生事件 i+1是React事件
const discreteEventPairsForSimpleEventPlugin = [
    'click', 'click',
    'dblclick', 'doubleClick'
]
export const  topLevelEventsToReactNames = new Map(); //存放原生事件对应的react合成事件 {click:onClick,dblclick:onDoubleClick }

export function registerSimpleEvents() {
  for(let i=0;i<discreteEventPairsForSimpleEventPlugin.length;i+=2){
      let topEvent = discreteEventPairsForSimpleEventPlugin[i];// 原生事件click;  dblclick
      const event = discreteEventPairsForSimpleEventPlugin[i+1];//react事件click;  doubleClick
      const capitalizedEvent = event[0].toUpperCase()+event.slice(1);//click=>Click; doubleClick=>DoubleClick
      const reactName = 'on'+capitalizedEvent;//react合成事件Click=>onClick; DoubleClick=>onDoubleClick
      topLevelEventsToReactNames.set(topEvent,reactName);//{click:onClick,dblclick:onDoubleClick }
      registerTwoPhaseEvent(reactName,[topEvent]);//(onClick,[click]);  (onDoubleClick,[dblclick])
  }
}